<!-- 树形菜单 -->
<template>
  <el-scrollbar max-height="100vh">
    <el-menu
      :collapse="isCollapse"
      active-text-color="#fad701"
      router
      text-color="#fff"
      background-color="#304156"
      :default-active="$route.path"
      class="el-menu-vertical-demo"
    >
      <!-- 首页 -->
      <el-menu-item
        v-for="item in sideList.slice(0, 1)"
        :key="item.path"
        :index="'/index/homepage'"
      >
        <el-icon>
          <component :is="item.meta.icon" />
        </el-icon>
        <template #title
          ><span>{{ $t(item.meta.title) }}</span></template
        >
      </el-menu-item>
      <!-- 其他选项 -->
      <el-sub-menu
        v-for="item in sideList.slice(1)"
        :key="item.path"
        :index="'/index/' + item.path"
      >
        <template #title>
          <el-icon>
            <component :is="item.meta.icon" />
          </el-icon>
          <span>{{ $t(item.meta.title) }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item
            v-for="item2 in item.children"
            :index="'/index/' + item.path + '/' + item2.path"
            v-show="item2.meta.show != false"
            :key="item2.path"
          >
            {{ $t(item2.meta.title) }}
          </el-menu-item>
        </el-menu-item-group>
      </el-sub-menu>
    </el-menu>
  </el-scrollbar>
</template>

<script>
import page from "@/router/page.js";
import {
  House,
  Histogram,
  ShoppingCart,
  Management,
  Setting,
  User,
} from "@element-plus/icons-vue";

export default {
  components: {
    House,
    Histogram,
    ShoppingCart,
    Management,
    User,
    Setting,
  },
  data() {
    return {};
  },
  created() {
    // 获取侧边菜单数据
    this.sideList = page;
  },
  // 是否展开的数据
  props: ["isCollapse"],
};
</script>

<style lang="less" scoped>
.el-menu-vertical-demo {
  min-height: 100vh;
  height: 100%;
  border: 0px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
}
</style>
